package com.mini.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with meng.
 * User: meng5
 * Date: 2019-10-30
 * Description:
 */
@Data
@FieldNameConstants
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "数据统计-分页参数")
public class MiniStatisticPageParamNew {

    private Integer pageNumber;
    private Integer pageSize;
    private Integer page = 1;
    private Integer size = 10;

    @ApiModelProperty(value = "日期字符串-开始日期,2019-01-01")
    private String dateStart;
    @ApiModelProperty(value = "日期字符串-结束日期,2019-01-02")
    private String dateEnd;
//    private String respIds;
//    @ApiModelProperty(value = "工作室id，多个可以用,隔开")
//    private String workRoomId;
    @ApiModelProperty(value = "业务id，多个可以用,隔开")
    private String miniLessonId;

//    @ApiModelProperty(value = "运营组id，多个可以用,隔开")
//    private String groupId;

    @ApiModelProperty(value = "负责人id，多个可以用,隔开")
    private String respId;

    @ApiModelProperty(value = "广告计划名")
    private String campaignName;

    @ApiModelProperty(value = "排序 asc:升序,desc:降序")
    private String sortType;

    @ApiModelProperty(value = "排序字段")
    private String sortColumn;

    @ApiModelProperty(value = "登录用户id")
    private Long userId;

    @ApiModelProperty(value = "渠道码")
    private String channelCode;

    @ApiModelProperty(value = "小课站点名称")
    private String miniLessonName;

    @ApiModelProperty(value = "课程分类id")
    private Long typeId;

    @ApiModelProperty(value = "课程名称")
    private String lessonName;

    @ApiModelProperty(value = "显示字段,ALL 为全部显示,其他情况为 字段名称用,分割")
    private String fields;
    @ApiModelProperty(value = "工作室id")
    private List<Long> deptIds;

    @ApiModelProperty(value = "sku")
    private String skuCode;

    @ApiModelProperty(value = "站点类型 0：飞天 1：传统")
    private Integer siteType;

    @ApiModelProperty(value = "星图站点")
    private String xingtuSite;

    @ApiModelProperty(value = "项目id")
    private String itemId;

    @ApiModelProperty(value = "组织架构类型 0组 1工作室 全部-1")
    private Integer groupType;

    @ApiModelProperty(value = "组织ids，以都逗号分割")
    private String groupIds;

    @ApiModelProperty(value = "计划id")
    private String planId;

    @ApiModelProperty(value = "创意")
    private String idea;

    @ApiModelProperty(value = "统计维度--SKU维度：sku_code,投手维度：resp_id,飞天站点维度：mini_lesson_id,计划维度：plan_id，创意：idea")
    private String dimension;

    @ApiModelProperty(value = "模糊匹配查询key")
    private String key;

    @ApiModelProperty(value = "课程id")
    private String lessonId;




    public Map<String, Object> toMap(){
        Map<String, Object> map = new HashMap();
        map.put("pageNumber", pageNumber);
        map.put("pageSize", pageSize);
        map.put("dateStart", dateStart);
        map.put("dateEnd", dateEnd);
        map.put("campaignName", campaignName);
//        map.put("workRoomId", convertToSet(workRoomId));
        map.put("miniLessonId", convertToSet(miniLessonId));
//        map.put("groupId", convertToSet(groupId));
        map.put("respId", convertToSet(respId));
        map.put("sortType", sortType);
        map.put("sortColumn", sortColumn);
        map.put("lessonName", lessonName);
        map.put("typeId", typeId);
        map.put("miniLessonName", miniLessonName);
        map.put("channelCode", channelCode);

        map.put("skuCode", skuCode);
        map.put("siteType", siteType);
        map.put("xingtuSite", xingtuSite);
        map.put("itemId", itemId);
        map.put("groupType", groupType);
        map.put("groupIds", groupIds);
        map.put("planId", planId);
        map.put("idea", idea);
        map.put("dimension", dimension);
        map.put("key", key);
        //分页参数
        if(pageNumber != null && pageSize != null){
            map.put("offset", (pageNumber - 1) * pageSize);
            map.put("limit", pageSize);
        }

        return map;
    }

    private String[] convertToSet(String str){
        if(StringUtils.isBlank(str)){
            return null;
        }

        String[] arr = str.replaceAll(" ", "").split(",");
        return arr;
    }



}